package com.ruoyi;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;


/**
 * 启动程序
 * 
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class RuoYiApplication {
    private static final Logger log = LoggerFactory.getLogger(RuoYiApplication.class);

    private static final String ENV_KEY = "env";
    private static final String PROFILE_KEY = "profile";

    public static void main(String[] args) {
        initEnvironment(args);
        // System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(RuoYiApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  AGS工作流启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
    }

    /**
     * args[0]:环境标识(dev/qa/prd)
     * args[1]:profile
     */
    private static void initEnvironment(String... args) {
        if (args == null || args.length <= 0) {
            return;
        }

        String env = args[0].trim();
        System.setProperty(ENV_KEY, env);

        String profile = null;
        if (args.length >= 2) {
            profile = args[1].trim();
            System.setProperty(PROFILE_KEY, profile);
        }
        log.info("env: {}, profile: {}", env, profile);
    }
}
